﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace Core.UnitOfWork
{
    public class UnitOfWork : IUnitOfWork
    {
        public ObjectContext Context { get; set; }

        public UnitOfWork(ObjectContext context)
        {
            this.Context = context;
        }

        public void Save()
        {
            Context.SaveChanges();
        }

        public bool LazyLoadingEnabled
        {
            get { return Context.ContextOptions.LazyLoadingEnabled; }
            set { Context.ContextOptions.LazyLoadingEnabled = value; }
        }

        public bool ProxyCreationEnabled
        {
            get { return Context.ContextOptions.ProxyCreationEnabled; }
            set { Context.ContextOptions.ProxyCreationEnabled = value; }
        }

        public string ConnectionString
        {
            get { return Context.Connection.ConnectionString; }
            set { Context.Connection.ConnectionString = value; }
        }
    }
}
